home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 46
/
Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso
/
-in_the_mag-
/
reader_requests
/
scilab
/
tests
/
calpol.tst
< prev
next >
Wrap
Text File
|
1999-09-16
|
13KB
|
260 lines
//
deff('[ok]=cmpr(h1,h2,eps)',['h1=h1-h2;';
'if norm(coeff(h1(2)))>eps then ok=0,else ok=1,end'])
comp(cmpr)
s=poly(0,'s');
//
//rationals
//
num=1;den=1+s;
eps=5000*%eps;
if cmpr(num/den,tlist('r',num,den,[]),eps)<>1 then pause,end
if cmpr(den\num,tlist('r',num,den,[]),eps)<>1 then pause,end
if cmpr(num./den,tlist('r',num,den,[]),eps)<>1 then pause,end
if cmpr(den.\num,tlist('r',num,den,[]),eps)<>1 then pause,end
num=1.5+s**3;
if cmpr(num/den,tlist('r',num,den,[]),eps)<>1 then pause,end
if cmpr(den\num,tlist('r',num,den,[]),eps)<>1 then pause,end
if cmpr(num./den,tlist('r',num,den,[]),eps)<>1 then pause,end
if cmpr(den.\num,tlist('r',num,den,[]),eps)<>1 then pause,end
//
h1=num/den;x=1.5;
if cmpr(h1+x,tlist('r',num+x*den,den,[]),eps)<>1 then pause,end
if cmpr(x+h1,tlist('r',num+x*den,den,[]),eps)<>1 then pause,end
if cmpr(h1-x,tlist('r',num-x*den,den,[]),eps)<>1 then pause,end
if cmpr(x-h1,tlist('r',-num+x*den,den,[]),eps)<>1 then pause,end
x=1.5+3*s;
if cmpr(h1+x,tlist('r',num+x*den,den,[]),eps)<>1 then pause,end
if cmpr(x+h1,tlist('r',num+x*den,den,[]),eps)<>1 then pause,end
if cmpr(h1-x,tlist('r',num-x*den,den,[]),eps)<>1 then pause,end
if cmpr(x-h1,tlist('r',-num+x*den,den,[]),eps)<>1 then pause,end
y=s**3;h2=x/y;
if cmpr(h1+h2,tlist('r',num*y+x*den,den*y,[]),eps)<>1 then pause,end
if cmpr(h1-h2,tlist('r',num*y-x*den,den*y,[]),eps)<>1 then pause,end
//
// concatenations
//
h1=num/den;x=1.5;
if cmpr([h1,x],tlist('r',[num,x],[den,1],[]),eps)<>1 then pause,end
if cmpr([x,h1],tlist('r',[x,num],[1,den],[]),eps)<>1 then pause,end
if cmpr([h1;x],tlist('r',[num;x],[den;1],[]),eps)<>1 then pause,end
if cmpr([x;h1],tlist('r',[x;num],[1;den],[]),eps)<>1 then pause,end
x=1.5+3*s;
if cmpr([h1,x],tlist('r',[num,x],[den,1],[]),eps)<>1 then pause,end
if cmpr([x,h1],tlist('r',[x,num],[1,den],[]),eps)<>1 then pause,end
if cmpr([h1;x],tlist('r',[num;x],[den;1],[]),eps)<>1 then pause,end
if cmpr([x;h1],tlist('r',[x;num],[1;den],[]),eps)<>1 then pause,end
y=-0.5+s**3;h2=x/y;
if cmpr([h1,h2],tlist('r',[num,x],[den,y],[]),eps)<>1 then pause,end
if cmpr([h1;h2],tlist('r',[num;x],[den;y],[]),eps)<>1 then pause,end
h1=[num/den,den/num];x=[0.3 1.5];
if cmpr([h1,x],tlist('r',[h1(2),x],[h1(3),ones(x)],[]),eps)<>1 then pause,end
if cmpr([x,h1],tlist('r',[x,h1(2)],[ones(x),h1(3)],[]),eps)<>1 then pause,end
if cmpr([h1;x],tlist('r',[h1(2);x],[h1(3);ones(x)],[]),eps)<>1 then pause,end
if cmpr([x;h1],tlist('r',[x;h1(2)],[ones(x);h1(3)],[]),eps)<>1 then pause,end
h1=[num/den;den/num];x=[0.3;-1.5];
if cmpr([h1,x],tlist('r',[h1(2),x],[h1(3),ones(x)],[]),eps)<>1 then pause,end
if cmpr([x,h1],tlist('r',[x,h1(2)],[ones(x),h1(3)],[]),eps)<>1 then pause,end
if cmpr([h1;x],tlist('r',[h1(2);x],[h1(3);ones(x)],[]),eps)<>1 then pause,end
if cmpr([x;h1],tlist('r',[x;h1(2)],[ones(x);h1(3)],[]),eps)<>1 then pause,end
x=[1.5+3*s;-1+s**3];
if cmpr([h1,x],tlist('r',[h1(2),x],[h1(3),ones(x)],[]),eps)<>1 then pause,end
if cmpr([x,h1],tlist('r',[x,h1(2)],[ones(x),h1(3)],[]),eps)<>1 then pause,end
if cmpr([h1;x],tlist('r',[h1(2);x],[h1(3);ones(x)],[]),eps)<>1 then pause,end
if cmpr([x;h1],tlist('r',[x;h1(2)],[ones(x);h1(3)],[]),eps)<>1 then pause,end
h1=[num/den,den/num];x=[1.5+3*s,-1+s**2];
if cmpr([h1,x],tlist('r',[h1(2),x],[h1(3),ones(x)],[]),eps)<>1 then pause,end
if cmpr([x,h1],tlist('r',[x,h1(2)],[ones(x),h1(3)],[]),eps)<>1 then pause,end
if cmpr([h1;x],tlist('r',[h1(2);x],[h1(3);ones(x)],[]),eps)<>1 then pause,end
if cmpr([x;h1],tlist('r',[x;h1(2)],[ones(x);h1(3)],[]),eps)<>1 then pause,end
h1=[num/den;den/num];y=-0.5+s**3;h2=[num/y;y*y/(y+1)];
if cmpr([h1,h2],tlist('r',[h1(2),h2(2)],[h1(3),h2(3)],[]),eps)<>1 then pause,end
if cmpr([h1;h2],tlist('r',[h1(2);h2(2)],[h1(3);h2(3)],[]),eps)<>1 then pause,end
h1=[num/den,den/num];y=-0.5+s**3;h2=[num/y,y*y/(y+1)];
if cmpr([h1,h2],tlist('r',[h1(2),h2(2)],[h1(3),h2(3)],[]),eps)<>1 then pause,end
if cmpr([h1;h2],tlist('r',[h1(2);h2(2)],[h1(3);h2(3)],[]),eps)<>1 then pause,end
//
// extraction
//
h1=[num/den,den/num];
if cmpr(h1(1,1),num/den,eps)<>1 then pause,end
if cmpr(h1(1,1:2),h1,eps)<>1 then pause,end
if cmpr(h1(1,[2 1]),[den/num,num/den],eps)<>1 then pause,end
h1=[num/den;den/num];
if cmpr(h1(2,1),den/num,eps)<>1 then pause,end
if cmpr(h1(1:2,1),h1,eps)<>1 then pause,end
if cmpr(h1([2 1],1),[den/num;num/den],eps)<>1 then pause,end
y=-0.5+s**3;h1=[num/den,den/num];h2=[num/den,den/num;num/y,y*y/(y+1)];
if cmpr(h2(2,1),num/y,eps)<>1 then pause,end
if cmpr(h2(1:2,1:2),h2,eps)<>1 then pause,end
if cmpr(h2([2 1],1),[num/y;num/den],eps)<>1 then pause,end
if cmpr(h2(:,1),[num/den;num/y],eps)<>1 then pause,end
if cmpr(h2(2,:),[num/y,y*y/(y+1)],eps)<>1 then pause,end
if cmpr(h2(:,:),h2,eps)<>1 then pause,end
//
// insertions
//
h1=[num/den,den/num];x=0.33;
hh=h1;hh(1,1)=x;if cmpr(hh,[x,h1(1,2)],eps)<>1 then pause,end;
x=[-2.67 0.8];
hh=h1;hh(1,1:2)=x;if cmpr(hh,x,eps)<>1 then pause,end;
hh=h1;hh(1,[2 1])=x;if cmpr(hh,x([2,1]),eps)<>1 then pause,end;
hh=h1;hh(1,[2;1])=x;if cmpr(hh,x([2,1]),eps)<>1 then pause,end;
hh=h1;hh(1,:)=x;if cmpr(hh,x,eps)<>1 then pause,end;
hh=h1;hh(:,:)=x;if cmpr(hh,x,eps)<>1 then pause,end;
h1=[num/den;den/num];x=0.33;
hh=h1;hh(1,1)=x;if cmpr(hh,[x;h1(2,1)],eps)<>1 then pause,end;
x=[-2.67;0.8];
hh=h1;hh(1:2,1)=x;if cmpr(hh,x,eps)<>1 then pause,end;
hh=h1;hh(:,1)=x;if cmpr(hh,x,eps)<>1 then pause,end;
hh=h1;hh(:,:)=x;if cmpr(hh,x,eps)<>1 then pause,end;
hh=h1;hh([2 1],1)=x;if cmpr(hh,x([2 1]),eps)<>1 then pause,end;
hh=h1;hh([2;1],1)=x;if cmpr(hh,x([2 1]),eps)<>1 then pause,end;
h1=[num/den,den/num];x=0.33*s+1;
hh=h1;hh(1,1)=x;if cmpr(hh,[x,h1(1,2)],eps)<>1 then pause,end;
x=[-2.67 0.8+s**3];
hh=h1;hh(1,1:2)=x;if cmpr(hh,x,eps)<>1 then pause,end;
hh=h1;hh(1,[2 1])=x;if cmpr(hh,x([2,1]),eps)<>1 then pause,end;
hh=h1;hh(1,[2;1])=x;if cmpr(hh,x([2,1]),eps)<>1 then pause,end;
hh=h1;hh(1,:)=x;if cmpr(hh,x,eps)<>1 then pause,end;
hh=h1;hh(:,:)=x;if cmpr(hh,x,eps)<>1 then pause,end;
h1=[num/den;den/num];x=-0.33+38*s;
hh=h1;hh(1,1)=x;if cmpr(hh,[x;h1(2,1)],eps)<>1 then pause,end;
x=[-2.67-s*8;0.8];
hh=h1;hh(1:2,1)=x;if cmpr(hh,x,eps)<>1 then pause,end;
hh=h1;hh(:,1)=x;if cmpr(hh,x,eps)<>1 then pause,end;
hh=h1;hh(:,:)=x;if cmpr(hh,x,eps)<>1 then pause,end;
hh=h1;hh([2 1],1)=x;if cmpr(hh,x([2 1]),eps)<>1 then pause,end;
hh=h1;hh([2;1],1)=x;if cmpr(hh,x([2 1]),eps)<>1 then pause,end;
h1=[num/den,den/num];y=0.33*s+1;x=y*y/(y+1);
hh=h1;hh(1,1)=x;if cmpr(hh,[x,h1(1,2)],eps)<>1 then pause,end;
x=[num/y,y*y/(y+1)];
hh=h1;hh(1,1:2)=x;if cmpr(hh,x,eps)<>1 then pause,end;
hh=h1;hh(1,[2 1])=x;if cmpr(hh,x(1,[2,1]),eps)<>1 then pause,end;
hh=h1;hh(1,[2;1])=x;if cmpr(hh,x(1,[2,1]),eps)<>1 then pause,end;
hh=h1;hh(1,:)=x;if cmpr(hh,x,eps)<>1 then pause,end;
hh=h1;hh(:,:)=x;if cmpr(hh,x,eps)<>1 then pause,end;
h1=[num/den;den/num];x=[num/y;y*y/(y+1)];
hh=h1;hh(1:2,1)=x;if cmpr(hh,x,eps)<>1 then pause,end;
hh=h1;hh(:,1)=x;if cmpr(hh,x,eps)<>1 then pause,end;
hh=h1;hh(:,:)=x;if cmpr(hh,x,eps)<>1 then pause,end;
hh=h1;hh([2 1],1)=x;if cmpr(hh,x([2 1],1),eps)<>1 then pause,end;
hh=h1;hh([2;1],1)=x;if cmpr(hh,x([2 1],1),eps)<>1 then pause,end;
//
// matrix operations
//
h1=[num/den,den/num];x=[0.3 1.5];
if cmpr(-h1,(-1)*h1,eps)<>1 then pause,end
if cmpr(h1+x,[h1(1,1)+x(1,1) h1(1,2)+x(1,2)],eps)<>1 then pause,end
if cmpr(x+h1,[h1(1,1)+x(1,1) h1(1,2)+x(1,2)],eps)<>1 then pause,end
if cmpr(h1-x,[h1(1,1)-x(1,1) h1(1,2)-x(1,2)],eps)<>1 then pause,end
if cmpr(x-h1,[-h1(1,1)+x(1,1) -h1(1,2)+x(1,2)],eps)<>1 then pause,end
h1=[num/den;den/num];x=[0.3;1.5];
if cmpr(-h1,(-1)*h1,eps)<>1 then pause,end
if cmpr(h1+x,[h1(1,1)+x(1,1); h1(2,1)+x(2,1)],eps)<>1 then pause,end
if cmpr(x+h1,[h1(1,1)+x(1,1); h1(2,1)+x(2,1)],eps)<>1 then pause,end
if cmpr(h1-x,[h1(1,1)-x(1,1); h1(2,1)-x(2,1)],eps)<>1 then pause,end
if cmpr(x-h1,[-h1(1,1)+x(1,1); -h1(2,1)+x(2,1)],eps)<>1 then pause,end
h1=[num/den,den/num];x=[0.3+s, 1.5];
if cmpr(-h1,(-1)*h1,eps)<>1 then pause,end
if cmpr(h1+x,[h1(1,1)+x(1,1) h1(1,2)+x(1,2)],eps)<>1 then pause,end
if cmpr(x+h1,[h1(1,1)+x(1,1) h1(1,2)+x(1,2)],eps)<>1 then pause,end
if cmpr(h1-x,[h1(1,1)-x(1,1) h1(1,2)-x(1,2)],eps)<>1 then pause,end
if cmpr(x-h1,[-h1(1,1)+x(1,1) -h1(1,2)+x(1,2)],eps)<>1 then pause,end
h1=[num/den;den/num];x=[0.3;1.5-3*s];
if cmpr(-h1,(-1)*h1,eps)<>1 then pause,end
if cmpr(h1+x,[h1(1,1)+x(1,1); h1(2,1)+x(2,1)],eps)<>1 then pause,end
if cmpr(x+h1,[h1(1,1)+x(1,1); h1(2,1)+x(2,1)],eps)<>1 then pause,end
if cmpr(h1-x,[h1(1,1)-x(1,1); h1(2,1)-x(2,1)],eps)<>1 then pause,end
if cmpr(x-h1,[-h1(1,1)+x(1,1); -h1(2,1)+x(2,1)],eps)<>1 then pause,end
//
//
h1=[num/den,den/num];
if cmpr([num,den]/den,[num/den,1],eps)<>1 then pause,end
if cmpr(den\[num,den],[num/den,1],eps)<>1 then pause,end
if cmpr([num,den]./[den,num],h1,eps)<>1 then pause,end
if cmpr([den,num].\[num,den],h1,eps)<>1 then pause,end
h1=[num/den,den/num];x=[0.3 1.5];
if cmpr(h1/x(1),[h1(1,1)/x(1),h1(1,2)/x(1)],eps)<>1 then pause,end
if cmpr(x(1)\h1,[h1(1,1)/x(1),h1(1,2)/x(1)],eps)<>1 then pause,end
if cmpr(h1./x,[h1(1,1)/x(1),h1(1,2)/x(2)],eps)<>1 then pause,end
if cmpr(x.\h1,[h1(1,1)/x(1),h1(1,2)/x(2)],eps)<>1 then pause,end
if cmpr(h1*x(1),[h1(1,1)*x(1),h1(1,2)*x(1)],eps)<>1 then pause,end
if cmpr(h1.*x,[h1(1,1)*x(1),h1(1,2)*x(2)],eps)<>1 then pause,end
h1=[num/den;den/num];
if cmpr([num;den]/den,[num/den;1],eps)<>1 then pause,end
if cmpr(den\[num;den],[num/den;1],eps)<>1 then pause,end
if cmpr([num;den]./[den;num],h1,eps)<>1 then pause,end
if cmpr([den;num].\[num;den],h1,eps)<>1 then pause,end
x=[0.3;1.5];
if cmpr(h1/x(1),[h1(1,1)/x(1);h1(2,1)/x(1)],eps)<>1 then pause,end
if cmpr(x(1)\h1,[h1(1,1)/x(1);h1(2,1)/x(1)],eps)<>1 then pause,end
if cmpr(h1./x,[h1(1,1)/x(1);h1(2,1)/x(2)],eps)<>1 then pause,end
if cmpr(x.\h1,[h1(1,1)/x(1);h1(2,1)/x(2)],eps)<>1 then pause,end
if cmpr(h1*x(1),[h1(1,1)*x(1);h1(2,1)*x(1)],eps)<>1 then pause,end
if cmpr(h1.*x,[h1(1,1)*x(1);h1(2,1)*x(2)],eps)<>1 then pause,end
if cmpr(h1'*x,h1(1,1)*x(1)+h1(2,1)*x(2),eps)<>1 then pause,end
if cmpr(h1*x',[h1(1,1)*x(1),h1(1,1)*x(2);h1(2,1)*x(1),h1(2,1)*x(2)],eps)<>1,
then pause,end
h1=[num/den,den/num];x=[0.3+3*s, 1.5];
if cmpr(h1/x(1),[h1(1,1)/x(1),h1(1,2)/x(1)],eps)<>1 then pause,end
if cmpr(x(1)\h1,[h1(1,1)/x(1),h1(1,2)/x(1)],eps)<>1 then pause,end
if cmpr(h1./x,[h1(1,1)/x(1),h1(1,2)/x(2)],eps)<>1 then pause,end
if cmpr(x.\h1,[h1(1,1)/x(1),h1(1,2)/x(2)],eps)<>1 then pause,end
if cmpr(h1*x(1),[h1(1,1)*x(1),h1(1,2)*x(1)],eps)<>1 then pause,end
if cmpr(h1.*x,[h1(1,1)*x(1),h1(1,2)*x(2)],eps)<>1 then pause,end
if cmpr(h1*x',h1(1,1)*x(1)+h1(1,2)*x(2),eps)<>1 then pause,end
if cmpr(h1'*x,[h1(1,1)*x(1),h1(1,1)*x(2);h1(1,2)*x(1),h1(1,2)*x(2)],eps)<>1,
then pause,end
h1=[num/den;den/num];x=[0.3+3*s; 1.5];
if cmpr(h1/x(1),[h1(1,1)/x(1);h1(2,1)/x(1)],eps)<>1 then pause,end
if cmpr(x(1)\h1,[h1(1,1)/x(1);h1(2,1)/x(1)],eps)<>1 then pause,end
if cmpr(h1./x,[h1(1,1)/x(1);h1(2,1)/x(2)],eps)<>1 then pause,end
if cmpr(x.\h1,[h1(1,1)/x(1);h1(2,1)/x(2)],eps)<>1 then pause,end
if cmpr(h1*x(1),[h1(1,1)*x(1);h1(2,1)*x(1)],eps)<>1 then pause,end
if cmpr(h1.*x,[h1(1,1)*x(1);h1(2,1)*x(2)],eps)<>1 then pause,end
if cmpr(h1'*x,h1(1,1)*x(1)+h1(2,1)*x(2),eps)<>1 then pause,end
if cmpr(h1*x',[h1(1,1)*x(1),h1(1,1)*x(2);h1(2,1)*x(1),h1(2,1)*x(2)],eps)<>1,
then pause,end
h1=[num/den,den/num];x=[0.3/s,1.5-s**2/(1+s**2)];
if cmpr(h1/x(1,1),[h1(1,1)/x(1,1),h1(1,2)/x(1,1)],eps)<>1 then pause,end
if cmpr(x(1,1)\h1,[h1(1,1)/x(1,1),h1(1,2)/x(1,1)],eps)<>1 then pause,end
if cmpr(h1./x,[h1(1,1)/x(1,1),h1(1,2)/x(1,2)],eps)<>1 then pause,end
if cmpr(x.\h1,[h1(1,1)/x(1,1),h1(1,2)/x(1,2)],eps)<>1 then pause,end
if cmpr(h1*x(1,1),[h1(1,1)*x(1,1),h1(1,2)*x(1,1)],eps)<>1 then pause,end
if cmpr(h1.*x,[h1(1,1)*x(1,1),h1(1,2)*x(1,2)],eps)<>1 then pause,end
h1=[num/den;den/num];x=[0.3/s;1.5-s**2/(1+s**2)];
if cmpr(h1/x(1,1),[h1(1,1)/x(1,1);h1(2,1)/x(1,1)],eps)<>1 then pause,end
if cmpr(x(1,1)\h1,[h1(1,1)/x(1,1);h1(2,1)/x(1,1)],eps)<>1 then pause,end
if cmpr(h1./x,[h1(1,1)/x(1,1);h1(2,1)/x(2,1)],eps)<>1 then pause,end
if cmpr(x.\h1,[h1(1,1)/x(1,1);h1(2,1)/x(2,1)],eps)<>1 then pause,end
if cmpr(h1*x(1,1),[h1(1,1)*x(1,1);h1(2,1)*x(1,1)],eps)<>1 then pause,end
if cmpr(h1.*x,[h1(1,1)*x(1,1);h1(2,1)*x(2,1)],eps)<>1 then pause,end
if cmpr(h1'*x,h1(1,1)*x(1,1)+h1(2,1)*x(2,1),eps)<>1 then pause,end
if cmpr(h1*x',[h1(1,1)*x(1,1),h1(1,1)*x(2,1)
h1(2,1)*x(1,1),h1(2,1)*x(2,1)],eps)<>1,
then pause,end
//
h1=h1*x';x=[1 2;3 4];
if cmpr(h1/x,h1*inv(x),eps)<>1 then pause,end
if cmpr(x\h1,inv(x)*h1,eps)<>1 then pause,end
x=[s s*s+s-1;1 s+1];xi=[1+s,1-s-s*s;-1 s];
if norm(coeff(invr(x)-xi))>eps then pause,end
if cmpr(h1/x,h1*xi,eps)<>1 then pause,end
if cmpr(x\h1,xi*h1,eps)<>1 then pause,end
if cmpr(x**(-1),xi,eps)<>1 then pause,end
x=[1/(1+s) 1/(s*(s+1))-1;1 1/s];xi=[1/s,-1/(s*(s+1))+1;-1,1/(1+s)];
if cmpr(invr(x),xi,eps)<>1 then pause,end
if cmpr(h1/x,h1*xi,eps)<>1 then pause,end
if cmpr(x\h1,xi*h1,eps)<>1 then pause,end
if cmpr((1/(1+s))**3,1/((1+s)**3),eps)<>1 then pause,end
x=[1/(1+s),1;0 1/s];x3=[x(1,1)**3,x(1,1)**2+x(2,2)*(x(2,2)+x(1,1));0,x(2,2)**3];
if cmpr(x**3,x3,eps)<>1 then pause,end